<#-- 
	Java Entity Class (template) Code generation template for Hibernate
	by   : Young Suk Ahn (Altenia Corp.)
	modif: 2012/07/04
-->
<#include "hbm2java_common.ftl">

<#macro default_val type>
<#if type?upper_case=="LONG" || type?upper_case=="INT" || type?upper_case=="INTEGER" || type?upper_case=="SHORT" || type?upper_case=="TINYINT" || type?upper_case=="SMALLINT" || type?upper_case=="SHORTINT">0<#elseif type?upper_case=="FLOAT" || type?upper_case=="DOUBLE" || type?upper_case=="DECIMAL">0.0<#elseif type?upper_case=="CHAR" || type?upper_case=="VARCHAR" || type?upper_case=="STRING" || type?upper_case=="TEXT" || type?upper_case=="DATE" || type?upper_case=="TIMESTAMP">null<#elseif type?upper_case=="BINARY" || type?upper_case=="BIN">null<#else>null</#if></#macro>

<#macro process_column xmlElement>
<#assign col_name = xmlElement.@name >
<#assign col_type = (xmlElement.@type[0])!"TYPE_MISSING" >
<#if col_type == "TYPE_MISSING" ><#assign col_type = (xmlElement.@class[0])!"TYPE_MISSING" ></#if>
<#assign col_primaryKey = (xmlElement.@primaryKey[0])!"" >
<#assign col_required = (xmlElement.@required[0])!"" >
<#assign col_size = (xmlElement.@length[0])!"" >
<#assign col_description = (xmlElement.meta[0])!"" >
<#if col_primaryKey != "" ><#assign attr_primaryKey = ", isPrimaryKey=${col_primaryKey}" ><#else><#assign attr_primaryKey = "" ></#if>
<#if col_required != "" ><#assign attr_required = ", isRequired=${col_required}" ><#else><#assign attr_required = "" ></#if>
<#if col_size != "" ><#assign attr_size = ", size=\"${col_size}\"" ><#else><#assign attr_size = "" ></#if>
	private <@print_java_type type=col_type /> ${col_name} = <@default_val type=col_type />; /* ${col_description} <#if col_size != "" >(length:${col_size})</#if> */ 
</#macro>
/**
 * Generated by ddl2java_entity_class.ftl
 */ 
<#assign classes = .node["hibernate-mapping/class"] >
<#list classes as class >
	<#assign class_name = class.@name>
	<#assign table_name = class.@table>
	<#assign namespace  = (class.@namespace[0])!"">
<#if namespace != "" >package ${namespace};<#else>package <@print_java_packagename fqName=class_name />;</#if>

import java.util.Date;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import com.seednia.foundation.framework.dto.AbstractRecord;
import com.seednia.foundation.framework.dto.ICriteria;
import com.seednia.foundation.framework.util.RecordUtils;

/**
 * Entity Class ${class_name}
 * Generated by hbm2java_entity_class.ftl (v2012/07/04)
 *
 */
@XmlRootElement(name = "<@print_java_modulename fqName=class_name />Criteria", 
		namespace = "http://seednia.com/core/1.0")
@XmlType(name = "<@print_java_modulename fqName=class_name />Criteria")
@XmlAccessorType(XmlAccessType.PROPERTY)
public class <@print_java_modulename fqName=class_name />Criteria extends <@print_java_classname fqName=class_name /> implements ICriteria {

	private Date createdBefore= null;
	private Date createdAfter= null;

	public <@print_java_modulename fqName=class_name />Criteria(){
		RecordUtils.initCriteria(this);
	}
	
	@Override
	public Date getCreatedBefore() {
		return createdBefore;
	}
	public void setCreatedBefore(Date createdBefore) {
		this.createdBefore = createdBefore;
	}

	@Override
	public Date getCreatedAfter() {
		return createdAfter;
	}
	public void setCreatedAfter(Date createdAfter) {
		this.createdAfter = createdAfter;
	}
	
	@Override
	public void setSearchText(String value)
	{
		// set all properties to search on
	}
	
	/**
	 * To create object (unmarshal) from JSONP string
	 * Used by the REST framework when sending this object as parameter
	 * @param jsonStr
	 * @return
	 */
	public static <@print_java_modulename fqName=class_name />Criteria fromString(String jsonStr) {
		<@print_java_modulename fqName=class_name />Criteria retval = (<@print_java_modulename fqName=class_name />Criteria) AbstractRecord.fromString(<@print_java_modulename fqName=class_name />Criteria.class, jsonStr);
		return retval;
	}
}
</#list>
